package com.mk.common.util;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

import org.junit.Test;

public class IOtest {
	@Test
	public void test1() {
//		File file = new File("D:/myDoc/CYHK/0719.txt");
//        System.out.println(file.exists()); // true
        
        File file = new File("D:/myDoc/CYHK/022.txt");
        System.out.println(file.exists()); // false
	}
	
	
	@Test
	public void test2() {
		File file = new File("D:/myDoc/CYHK/ASS/");
		if(!file.exists()) {
			file.mkdir();
		}
		System.out.println(file.exists()); // true 
		System.out.println(file.getPath() );
	}
	
	@Test
	public void test3() {
		File file = new File("D:/myDoc/CYHK/2223.txt");
		if(file.exists()) {
			file.delete();
		}
		System.out.println(file.exists()); //  false 
	}
	
	@Test
	public void test4() {
		File file = new File("D:/myDoc/CYHK/2223.txt");
		file.delete();
		
		System.out.println("0000"); //√√√
	}
	
	@Test
	public void test5() {
		File file = new File("D:/myDoc/CYHK/");
		System.out.println(file.exists());  // true
	}
	
	
	@Test
	public void test6() {
		System.out.println(File.separator); // \
		System.out.println(File.separatorChar);// \
		System.out.println(File.pathSeparator); // ;
		System.out.println(File.pathSeparatorChar); // ;
	}
	
	@Test
	public void test7() {
		File ifl = new File("D:/myDoc/CYHK/2223.txt");
		System.out.println(ifl.exists()); // false,  不会主动生成   
		
		File file = new File("D:/myDoc/CYHK", "23.txt");
		System.out.println(file.exists()); // false, 不会主动生成   
	}
	
	@Test
	public void test8() throws IOException {
		FileOutputStream out = new FileOutputStream("D:/myDoc/CYHK/2223.txt");
		out.close();
	}
	
	@Test
	public void test9() {
		File f = new File("D:/myDoc/CYHK/2222");
		System.out.println(f.exists());// false.  不会主动生成   
	}
	
	@Test
	public void test10() {
		File file = new File("D:/myDoc/CYHK", "0719.txt");
		System.out.println(file);
		System.out.println(file.exists());
		
		File f = new File("D:/myDoc/CYHK/0722.txt");
		System.out.println(f);
		System.out.println(f.exists());
	}
	
	@Test
	public void test11() throws Exception {
//		OutputStream out = new FileOutputStream("D:/myDoc/CYHK/0722.txt"); // error ,找不到路径
		OutputStream out = new FileOutputStream("D:/myDoc/0722.txt"); // 
	}
	
	
	
}
